<script>
export default {
  data() {
    return {
      filesList: [],
      total: 0,
      currentPage: 1,
      size: 5,
      multipleSelection: [],
      name: '',
      dialogFormVisible: false,
      form: {}
    }
  },
  created() {
    this.getFilesList()
  },
  methods: {
    getFilesList() {
      this.request.get('/file/findAll/' + `${this.currentPage}` + "/" + `${this.size}` + "?name=" + `${this.name}`)
          .then(res => {
            console.log(res)
            this.total = res.count
            this.filesList = res.filesList
          })
    },
    clear() {
      this.name = ''
    },
    // 每页数
    handleSizeChange(val) {
      this.size = val
      this.currentPage = 1
      this.getFilesList()
    },
    // 当前页
    handleCurrentChange(val) {
      this.currentPage = val
      this.getFilesList()
    },
    download(url){
      window.open(url)
    }

  }
}
</script>

<template>
  <div >



    <div style="padding: 10px 0">
      <el-input style="width: 250px" suffix-icon="el-icon-search" placeholder="请输入文件名称"
                v-model="name"></el-input>
      <el-button type="primary" style="margin-left: 5px" @click="getFilesList">搜索</el-button>
      <el-button type="danger" style="margin-left: 5px" @click="clear()">清空</el-button>


    </div>

    <el-table :data="filesList" border stripe  style="width: 100%;">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>

      <el-table-column align="center" prop="name" label="文件名称" width="300">
      </el-table-column>
      <el-table-column align="center" prop="type" label="文件类型" width="200">
      </el-table-column>
      <el-table-column align="center" prop="size" label="文件大小(kb)" width="150">
      </el-table-column>
      <el-table-column align="center" prop="createTime" label="创建时间" width="200">
      </el-table-column>
      <el-table-column align="center" prop="updateTime" label="修改时间" width="200">
      </el-table-column>




            <el-table-column label="操作" width="310" align="center">
              <template slot-scope="scope">
                <el-button type="primary" @click="download(scope.row.url)">下载<i style="margin-left: 2px"
                                                                                class="el-icon-edit"></i></el-button>

              </template>
            </el-table-column>
    </el-table>

    <div style="padding: 10px 0;margin-left: 460px">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[8, 10, 15, 20]"
          :page-size="size"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
      >
      </el-pagination>
    </div>

    <el-dialog title="名言信息" :visible.sync="dialogFormVisible">
      <el-form label-width="70px" size="big">
        <el-form-item label="名言">
          <el-input v-model="form.sentence" autocomplete="off"></el-input>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="saveOrUpdate">确 定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<style scoped>

</style>